package com.wangxiaotao.Dao;

import com.wangxiaotao.Pojo.Goods;
import com.wangxiaotao.Pojo.Order;
import com.wangxiaotao.Pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AdminDao {
    @Delete("DELETE FROM orders WHERE order_id=#{order_id}")
    void deleteoder(int order_id);

    @Select("SELECT * FROM orders  WHERE isok=0")
    List<Order> getoderlist();

    @Update("UPDATE orders SET isok=1 WHERE order_id=#{order_id}")
    void setisok(int order_id);

    @Update("UPDATE orders SET name=#{name},order_count=#{order_count},order_price=#{order_price},address=#{address},tel=#{tel} WHERE order_id=#{order_id}")
    void updataorder(Order user_order);

    @Insert("INSERT into orders (order_num,name,order_count,order_time,order_price,address,tel) VALUES " +
            "(#{order_num},#{name},#{order_count},#{order_time},#{order_price},#{address},#{tel})")
    void addoeder(Order order);

    @Select("SELECT * FROM orders ORDER BY order_num DESC LIMIT 1")
    Order getordernum();

    @Select("SELECT * FROM orders  WHERE isok=1")
    List<Order> isokorders();

    @Select("SELECT * FROM orders WHERE isok=0")
    List<Order> unisokorders();

    @Select("SELECT * FROM orders")
    List<Order> allorders();

    @Select("SELECT * FROM goods")
    List<Goods> getallgoods();

    @Select("SELECT * FROM goods WHERE goods_type BETWEEN 1 AND 4")
    List<Goods> getmeishigoods();

    @Select("SELECT * FROM goods WHERE goods_type BETWEEN 5 AND 7")
    List<Goods> getyinpingoods();

    @Select("SELECT * FROM goods WHERE goods_type BETWEEN 8 AND 9")
    List<Goods> getshuiguogoods();

    @Delete("DELETE FROM goods WHERE goods_id=#{goods_id}")
    void deletefood(int goods_id);

    @Update("UPDATE goods SET goods_name=#{goods_name},goods_price=#{goods_price} WHERE goods_id=#{goods_id}")
    void updatagoods(Goods goods);

    @Select("SELECT * FROM user")
    List<User> getalluser();

    @Update("UPDATE user SET name=#{name},username=#{username},password=#{password},address=#{address},tel=#{tel},sex=#{sex},discrib=#{discrib} WHERE user_id=#{user_id}")
    void updatauser(User user);

    @Delete("DELETE FROM user WHERE user_id=#{user_id}")
    void deleteuser(int user_id);

    @Insert("INSERT into goods (goods_id,goods_name,goods_price,goods_url,goods_type) VALUES " +
            "(#{goods_id},#{goods_name},#{goods_price},#{goods_url},#{goods_type})")
    void addgoods(Goods goods);

    @Select("SELECT * FROM goods ORDER BY goods_id DESC LIMIT 1")
    Goods getmaxgoodid();
}
